import {defineConfig} from "umi";
import proxy from "./proxy";

const {REACT_APP_ENV} = process.env;
export default defineConfig({
  esbuild: {},
  hash: true,
  antd: {},
  dva: {
    hmr: true,
  },
  history: {
    type: 'hash', // 使用hash路由模式
  },
  locale: {
    default: "zh-CN",
    antd: true,
    baseNavigator: true,
  },
  targets: {
    ie: 11,
  },
  // umi routes:  https://umijs.org/docs/routing
  routes: [
    {
      path: "/FingerprintEntry",
      component: "./FingerprintEntry/index.tsx",
    },
    {
      path: "/Allocation",
      component: "./Allocation/index.tsx",
    },
    {
      path: "/Assist",
      component: "./Assist/index.jsx",
    },
    {
      path: "/tokenIP",
      component: "./tokenIP/index.jsx",
    },
    {
      path: "/popup",
      component: "./popup/index.tsx",
    },
    // {
    //   path: "/test2",
    //   component: "./test2/index.tsx",
    // },
    // {
    //   //path: "/test",
    //   component: "./test/index.tsx",
    // },
    {
      component: "./index.tsx",
    },
  ],
  __dirname: false,
  externals: {
    // 将模块名作为键，值为require中对应的全局变量名
    "child_process": "require('child_process')",
    "path": "require('path')",
    "process": "require('process')",
    "net": "require('net')",
    "fs": "require('fs')",
    "nw.gui":"require('nw.gui')"
  },

  // @ts-ignore
  title: false,
  ignoreMomentLocale: true,
  proxy: proxy[REACT_APP_ENV || "dev"],
  manifest: {
    basePath: "/",
  },
  chainWebpack(memo) {
    memo.module
        .rule('media')
        .test(/\.(mp3|4)$/)
        .use('file-loader')
        .loader(require.resolve('file-loader'))
  },
});
